package frontend.reports;

import backend.model.base.DBModel;

import java.util.Date;

public class XLSFileRowCreator {
    private int rowLength;

    public XLSFileRowCreator(int rowLength) {
        this.rowLength = rowLength;
    }

    public Object[] newRow() {
        Object[] row =  new Object[rowLength];
        return row;
    }

    public void addDateCell(Object[] row, int cellIndex, Date date) {
        row[cellIndex] = date;
    }

    public void addDBModelCell(Object[] row, int cellIndex, DBModel object) {
        addStringCell(row, cellIndex, object != null ? object.getDisplayLabel() : "-");
    }

    public void addHoursCell(Object[] row, int cellIndex, int hours) {
        row[cellIndex] = new Double(hours);
    }

    public void addStringCell(Object[] row, int cellIndex, String value) {
        if (value != null) {
            row[cellIndex] = value;
        } else {
            row[cellIndex] = "-";
        }
    }
}